package org.example.juc.sync.v6;

/**
 * Copyright (C), 2022, szw
 * FileName: SynchronizedTestV6
 *
 * @author songyafei
 * Date:     2022/1/25 9:39
 * Description: 版本6
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
public class SynchronizedTestV6 implements Runnable {

    private int count = 10;

    @Override
    public synchronized void run() {
        count--;
        System.out.println(Thread.currentThread().getName() + " count = " + count);
    }

    public static void main(String[] args) {

        for(int i=0; i<5; i++) {
            SynchronizedTestV6 t = new SynchronizedTestV6();
            new Thread(t, "THREAD" + i).start();
        }
    }
}
